package com.ysx.student.zhangqingrong.com.ysx.day3;

/**
 * @author 张青荣
 */
public class DemoTe3 {

    public static void main(String[] args) {

        // 1+3+5+7...+99

        // 2  3 4 5... 100 或者

        int sum = getSum();
        System.out.println(sum);
    }

    private static int getSum() {
        int sum = 0;

        // 笔试
        int begin = 2;
        int end = 100;
        while (begin <= end) {

            // 只有偶数才累加
            if (begin % 2 == 0) {
                sum = sum + begin;
            }
            begin = begin + 1;
        }
        return sum;
    }
}






